﻿package kliment.display.draw.shape {
	import flash.display.Graphics;
	import flash.display.Shape;
	import kliment.display.draw.DrawStyle;

	/**
	 * ...
	 * @author Kliment
	 */
	public class ShapeAbstract extends Shape {

		public function ShapeAbstract() {
			super();
		}

		static protected function _setStyles(target:Graphics, drawStyle:DrawStyle = null):void {
			if (!drawStyle) drawStyle = new DrawStyle();

			if (drawStyle.fillBitmap)
				target.beginBitmapFill(drawStyle.fillBitmap.bitmap, drawStyle.fillBitmap.matrix, drawStyle.fillBitmap.repeat, drawStyle.fillBitmap.smooth);
			else if (drawStyle.fillGradientStyle)
				target.beginGradientFill(drawStyle.fillGradientStyle.type, drawStyle.fillGradientStyle.colors, drawStyle.fillGradientStyle.alphas, drawStyle.fillGradientStyle.ratios, drawStyle.fillGradientStyle.matrix, drawStyle.fillGradientStyle.spreadMethod, drawStyle.fillGradientStyle.interpolationMethod, drawStyle.fillGradientStyle.focalPointRatio);
			else if (drawStyle.fillColorStyle)
				target.beginFill(drawStyle.fillColorStyle.color, drawStyle.fillColorStyle.alpha);

			if (drawStyle.lineStyle)
				target.lineStyle(drawStyle.lineStyle.width, drawStyle.lineStyle.color, drawStyle.lineStyle.alpha, drawStyle.lineStyle.pixelHinting, drawStyle.lineStyle.scaleMode, drawStyle.lineStyle.caps, drawStyle.lineStyle.joints, drawStyle.lineStyle.miterLimit);
			if (drawStyle.lineGradientStyle)
				target.lineGradientStyle(drawStyle.lineGradientStyle.type, drawStyle.lineGradientStyle.colors, drawStyle.lineGradientStyle.alphas, drawStyle.lineGradientStyle.ratios, drawStyle.lineGradientStyle.matrix, drawStyle.lineGradientStyle.spreadMethod, drawStyle.lineGradientStyle.interpolationMethod, drawStyle.lineGradientStyle.focalPointRatio)
		}

		public function remove():void {
			if (parent)
				parent.removeChild(this);
		}
	}
}